home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / shell / ghel / src / parts.c < prev    next >
C/C++ Source or Header  |  1995-08-04  |  5KB  |  386 lines

  1. /*
  2.     
  3.     GHEL v1.2        [呼び出し関数、他]
  4.     
  5.         Programmed by Keijiro Takahashi (novice)
  6.     
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <msdos.cf>
  12. #include <time.h>
  13. #include <winb.h>
  14. #include <te.h>
  15. #include <fntb.h>
  16. #include <gui.h>
  17. #include <egb.h>
  18. #include <wgb.h>
  19. #include <file_dlg.h>
  20. #include <guidbg.h>
  21. #include "type.h"
  22. #include "hel.h"
  23.  
  24.  
  25. char *filedlg();
  26. void alert(char *altmsg);
  27. int prevhel(hel *buf);
  28. int revhel(hel *buf);
  29. int dsphel(hel *buf);
  30.  
  31.  
  32.  
  33. extern char *guiEgbPtr;
  34.  
  35. hel helbuf;
  36. int helstatus = NODATA;
  37. int helwait = 0;
  38. int    alertDlg = -1 ;
  39. int    alertMsg = -1 ;
  40. int    alertExecBtn = -1 ;
  41. int    backHyper1 = -1 ;
  42. int    baseWin = -1 ;
  43. int    cntrlDlg = -1 ;
  44. int    playBtn = -1 ;
  45. int    fileBtn = -1 ;
  46. int    cntrlBar = -1 ;
  47. int    pageMsg = -1 ;
  48. int    waitNumbox = -1 ;
  49. int    helWin = -1 ;
  50. int    backHyper2 = -1 ;
  51. char pageStr[10]="   0/0   ";
  52.  
  53.  
  54.  
  55.  
  56.  
  57. int    shell(kobj, messId, argc, pev, trigger)
  58. int        kobj ;
  59. int        messId ;
  60. int        argc ;
  61. EVENT    *pev ;
  62. int        trigger ;
  63. {
  64.     int ret=ILLEGAL_FUNCTION;
  65.  
  66.     switch (messId)
  67.     {
  68.         case GM_QUIT:
  69.             MMI_SetHaltFlag(TRUE);
  70.             ret = NOERR;
  71.             break;
  72.         
  73.         case GM_WAKE:
  74.             MMI_SendMessage(baseWin,MM_WAKE,0);
  75.             ret = NOERR;
  76.             break;
  77.         
  78.         case GM_SLEEP:
  79.             MMI_SendMessage(baseWin,MM_SLEEP,0);
  80.             ret = NOERR;
  81.             break;
  82.     }
  83.  
  84.     return(ret);
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91. int    alertFunc(kobj, messId, argc, pev, trigger)
  92. int        kobj ;
  93. int        messId ;
  94. int        argc ;
  95. EVENT    *pev ;
  96. int        trigger ;
  97. {
  98.     MMI_SetHaltFlag(TRUE);
  99.     return NOERR ;
  100. }
  101.  
  102.  
  103.  
  104.  
  105.  
  106. int    baseWinFunc(kobj, messId, argc, pev, trigger)
  107. int        kobj ;
  108. int        messId ;
  109. int        argc ;
  110. EVENT    *pev ;
  111. int        trigger ;
  112. {
  113.     if (messId==MM_ERASE)
  114.     {
  115.         MMI_SetHaltFlag(TRUE);
  116.     }
  117.  
  118.     return(ILLEGAL_FUNCTION);
  119. }
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127. int    BtnFunc(kobj, messId, argc, pev, trigger)
  128. int        kobj ;
  129. int        messId ;
  130. int        argc ;
  131. EVENT    *pev ;
  132. int        trigger ;
  133. {
  134.     if (kobj==fileBtn)
  135.     {
  136.         helstatus = STOP;
  137.         if ( filedlg(helbuf.pathname) != NULL )
  138.         {
  139.             if(loadhel(helbuf.pathname,&helbuf)==0)
  140.             {
  141.                 helcnv(&helbuf);
  142.                 dsphel(&helbuf);
  143.                 helstatus=STOP;
  144.             }
  145.         }
  146.     }
  147.     else if (kobj==playBtn)
  148.     {
  149.         helstatus = (helstatus==PLAY) ? STOP : PLAY;
  150.     }
  151.  
  152.     return(NOERR);
  153. }
  154.  
  155.  
  156.  
  157.  
  158.  
  159. int    cntrlBarFunc(kobj, messId, argc, pev, trigger)
  160. int        kobj ;
  161. int        messId ;
  162. int        argc ;
  163. EVENT    *pev ;
  164. int        trigger ;
  165. {
  166.     int dum;
  167.     
  168.     MMI_SendMessage(cntrlBar,MM_GETSCROLL,5,&(helbuf.page)
  169.                                             ,&dum,&dum,&dum,&dum);
  170.     
  171.     dsphel(&helbuf);
  172.     
  173.     return NOERR ;
  174. }
  175.  
  176.  
  177.  
  178.  
  179.  
  180. int    helWinFunc(kobj, messId, argc, pev, trigger)
  181. int        kobj ;
  182. int        messId ;
  183. int        argc ;
  184. EVENT    *pev ;
  185. int        trigger ;
  186. {
  187.     if (messId==MM_SHOW)
  188.     {
  189.         if (helbuf.buf!=NULL)
  190.         {
  191.             PBC_para para;
  192.             
  193.             para.slct = getds();
  194.             para.x1   = 0;
  195.             para.y1   = 0;
  196.             para.x2   = 159;
  197.             para.y2   = 119;
  198.             para.adr  = helbuf.buf+helbuf.page*2400;
  199.             
  200.             EGB_color(guiEgbPtr,0,MG_colorChange(15));
  201.             EGB_color(guiEgbPtr,1,MG_colorChange(8));
  202.             EGB_writeMode(guiEgbPtr,9);
  203.             
  204.             WGB_putBlockColor(guiEgbPtr,1,(char *)¶);
  205.         }
  206.     }
  207.  
  208.     return(ILLEGAL_FUNCTION);
  209. }
  210.  
  211.  
  212.  
  213.  
  214.  
  215. int    waitNumboxFunc(kobj, messId, argc, pev, trigger)
  216. int        kobj ;
  217. int        messId ;
  218. int        argc ;
  219. EVENT    *pev ;
  220. int        trigger ;
  221. {
  222.     int dum;
  223.  
  224.     MMI_SendMessage(waitNumbox,MM_GETNUMBOX,5,&helwait,&dum,&dum,&dum,&dum); 
  225.     
  226.     return NOERR ;
  227. }
  228.  
  229.  
  230.  
  231.  
  232.  
  233. /*
  234.     
  235.     以下、呼び出し関数以外の下請け関数
  236.     
  237. */
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246. /*
  247.  
  248.     Idle Task
  249.  
  250. */
  251. void idleTask()
  252. {
  253.     static clock_t count_st=0;
  254.  
  255.     if (helstatus==PLAY)
  256.     {
  257.         if ( (clock()-count_st) > helwait )
  258.         {
  259.             count_st=clock();
  260.             prevhel(&helbuf);
  261.         }
  262.     }
  263.  
  264.     return;
  265. }
  266.  
  267.  
  268.  
  269.  
  270.  
  271. /*
  272.  
  273.     display
  274.  
  275. */
  276. int dsphel(hel *buf)
  277. {
  278.     sprintf(pageStr,"%4d/%-4d",buf->page_max,buf->page);
  279.     MMI_SendMessage(pageMsg,MM_SHOW,0); 
  280.     MMI_SendMessage(pageMsg,MM_SHOW,0); 
  281.  
  282.     MMI_SendMessage(cntrlBar,MM_SETSCROLL,5,buf->page,0,buf->page_max,1,0);
  283.     MMI_SendMessage(cntrlBar,MM_SHOW,0);
  284.     
  285.     MMI_SendMessage(helWin,MM_SHOW,0); 
  286.  
  287.     return(NOERR);
  288. }
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295. /*
  296.  
  297.     preview
  298.  
  299. */
  300. int prevhel(hel *buf)
  301. {
  302.     if(++buf->page>buf->page_max)
  303.     {
  304.         buf->page=0;
  305.     }
  306.     dsphel(&helbuf);
  307.  
  308.     return(NOERR);
  309. }
  310.  
  311.  
  312.  
  313.  
  314.  
  315. /*
  316.  
  317.     review
  318.  
  319. */
  320. int revhel(hel *buf)
  321. {
  322.     if(--buf->page<0)
  323.     {
  324.         buf->page=buf->page_max;
  325.     }
  326.     dsphel(&helbuf);
  327.  
  328.     return(NOERR);
  329. }
  330.  
  331.  
  332.  
  333.  
  334.  
  335. /*
  336.  
  337.     ファイルダイヤログ
  338.  
  339. */
  340. char *filedlg(char *pathname)
  341. {
  342.     static char *wildcard[] = {"*.hel",NULL};
  343.     unsigned int dum1;
  344.     int ret,dum2;
  345.  
  346.     FDG_SetTitle("読 込","読 込","取 消");
  347.     
  348.     ret = FDG_DspFileDlg(    backHyper2,
  349.                             FDG_ALERT | FDG_SLCTCHK | FDG_FILEONLY,
  350.                             NULL,wildcard,&dum1 );
  351.     
  352.     if (ret)
  353.     {
  354.         FDG_GetPathName(pathname,&dum2,0); 
  355.     }
  356.     else
  357.     {
  358.         return(NULL);
  359.     }
  360.     
  361.     return(pathname);
  362. }
  363.  
  364.  
  365.  
  366.  
  367.  
  368. /*
  369.  
  370.     アラート
  371.  
  372. */
  373. void alert(char *altmsg)
  374. {
  375.     MMI_SendMessage(alertMsg,MM_SETMSG,1,altmsg);
  376.     MMI_SendMessage(alertDlg,MM_ATTACH,1,backHyper2);
  377.     MMI_SendMessage(alertDlg,MM_SHOW,0);
  378.     
  379.     MMI_ExecSystem();
  380.     
  381.     MMI_SendMessage(alertDlg,MM_ERASE,0);
  382.     MMI_SendMessage(alertDlg,MM_DETACH,0);
  383.  
  384.     return;
  385. }
  386.